package org.boyan.common.util.jsonschema.validate;

import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import java.util.HashMap;
import java.util.Map;
import org.boyan.common.util.jsonschema.CommonProperty;

/**
 * @author: zhuxiaobao
 * @time: 2021/9/24 16:03
 */

public class SwitchProperty extends CommonProperty {
    private String l;

    public SwitchProperty() {}

    public SwitchProperty(String key, String title, String extendStr) {
        this.b = "string";
        this.e = "switch";
        this.a = key;
        this.f = title;
        this.l = extendStr;
    }

    @Override
    public Map<String, Object> getPropertyJson() {
        HashMap<Object, Object> hashMap = new HashMap<>();
        hashMap.put("key", getKey());
        JSONObject jSONObject = getCommonJson();
        JSONArray jSONArray = new JSONArray();
        if (this.l != null) {
            jSONArray = JSONArray.parseArray(this.l);
            jSONObject.put("extendOption", jSONArray);
        }
        hashMap.put("prop", jSONObject);
        return (Map)hashMap;
    }
}
